<template>
  <div>
    <el-dialog
      v-if="editFormVisible"
      :title="title"
      :visible.sync="editFormVisible"
      width="50%"
      :close-on-click-modal="false"
    >
      <el-form ref="editShopImg" :model="editShopImg" :rules="rules" label-width="150px">
        <el-form-item label="适用门店组图片上传" prop="fileList">
          <el-upload
            class="upload-demo"
            action=""
            :headers="dataObj"
            :on-preview="handlePreview"
            :on-remove="handleRemove"
            :before-upload="beforeUpload"
            :file-list="fileList"
            list-type="picture"
          >
            <el-button size="small" type="primary">
              点击上传
            </el-button>
            <div slot="tip" class="el-upload__tip">
              只能上传jpg/png文件，且不超500kb
            </div>
          </el-upload>
        </el-form-item>
        <div class="save-btn">
          <el-button type="primary" size="small" @click="submitFile">
            保存
          </el-button>
        </div>
      </el-form>
      <!-- <div slot="footer" class="dialog-footer">
        <el-button size="small" @click="closeDialog">
          取消
        </el-button>
        <el-button size="small" type="primary" :loading="loading" class="title" @click="submitForm('editForm')">
          保存
        </el-button>
      </div> -->
    </el-dialog>
  </div>
</template>

<script>
import axios from 'axios'
export default {
  data () {
    return {
      editFormVisible: [],
      fileList: [],
      logo: ''
    }
  },
  methods: {
    submitFile () {
      const formData = new FormData()
      formData.append('file', this.uploadFile)
      axios({
        method: 'put',
        url: '/upload/setFileUpload',
        data: formData,
        headers: {
          // eslint-disable-next-line no-undef
          // Authorization: Cookies.get('loginToken')
        }
      }).then((res) => {
        // eslint-disable-next-line no-console
        console.log(res.data, 'res.data')
        this.dialogVisibleShopImg = false
        if (res.data.code === 200 & res.data.success === true) {
          this.$message({
            message: '提交成功',
            type: 'success'
          })
        } else {
          this.$message({
            message: '保存失败',
            type: 'error'

          })
        }
      })
    }
  }
}
</script>
<style lang="scss">
  .avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
  .avatar-uploader-icon {
    font-size: 18px;
    color: #8c939d;
    width: 100px;
    height: 100px;
    line-height: 100px;
    text-align: center;
  }
  .avatar {
    width: 100px;
    height: 100px;
    display: block;
  }
</style>
